{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import torch,torchvision\n",
    "import torchvision.datasets as datasets\n",
    "import torch.nn.parallel as parallel\n",
    "import os\n",
    "torch.backends.cudnn.enabled = True # 默认就是开启的状态\n",
    "torch.backends.cudnn.benchmark = True # 使用下面的语句来查看和设置是否使用cudnn,如果网络输入结构不变的话，那就可以很好的加速，但是如果网络输入层和中间层 的维度一直变来变去的话，最好是不用的\n",
    "torch.backends.cudnn.deterministic = True"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/home/hx/anaconda3/envs/DL/lib/python3.7/site-packages/torchvision/models/googlenet.py:73: FutureWarning: The default weight initialization of GoogleNet will be changed in future releases of torchvision. If you wish to keep the old behavior (which leads to long initialization times due to scipy/scipy#11299), please set init_weights=True.\n",
      "  ' due to scipy/scipy#11299), please set init_weights=True.', FutureWarning)\n"
     ]
    }
   ],
   "source": [
    "#\n",
    "google_net = torchvision.models.googlenet(pretrained=False)\n",
    "google_net.cuda()\n",
    "\n",
    "google_net = torch.nn.DataParallel(google_net,device_ids=[0],output_device=0)\n",
    "criterion = torch.nn.CrossEntropyLoss()\n",
    "optimizer = torch.optim.Adam(params=google_net.parameters(),lr=1e-4)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.0001\n"
     ]
    },
    {
     "data": {
      "text/plain": "1"
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "for i in optimizer.param_groups:\n",
    "    print(i['lr'])\n",
    "len(optimizer.param_groups)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "PATH\n",
      "LC_MEASUREMENT\n",
      "XAUTHORITY\n",
      "INVOCATION_ID\n",
      "XMODIFIERS\n",
      "LC_TELEPHONE\n",
      "XDG_DATA_DIRS\n",
      "GDMSESSION\n",
      "LC_TIME\n",
      "CONDA_DEFAULT_ENV\n",
      "PAPERSIZE\n",
      "GTK_IM_MODULE\n",
      "DBUS_SESSION_BUS_ADDRESS\n",
      "XDG_CURRENT_DESKTOP\n",
      "CONDA_PREFIX\n",
      "JOURNAL_STREAM\n",
      "SSH_AGENT_PID\n",
      "QT4_IM_MODULE\n",
      "LC_PAPER\n",
      "SESSION_MANAGER\n",
      "USERNAME\n",
      "LOGNAME\n",
      "PWD\n",
      "MANAGERPID\n",
      "IM_CONFIG_PHASE\n",
      "LANGUAGE\n",
      "GJS_DEBUG_TOPICS\n",
      "PYTHONPATH\n",
      "SHELL\n",
      "LC_ADDRESS\n",
      "GIO_LAUNCHED_DESKTOP_FILE\n",
      "OLDPWD\n",
      "GNOME_DESKTOP_SESSION_ID\n",
      "GTK_MODULES\n",
      "CLUTTER_IM_MODULE\n",
      "CONDA_PROMPT_MODIFIER\n",
      "XDG_SESSION_DESKTOP\n",
      "SHLVL\n",
      "LC_IDENTIFICATION\n",
      "LC_MONETARY\n",
      "QT_IM_MODULE\n",
      "XDG_CONFIG_DIRS\n",
      "LANG\n",
      "XDG_SESSION_TYPE\n",
      "DISPLAY\n",
      "LIBVIRT_DEFAULT_URI\n",
      "LC_NAME\n",
      "CONDA_SHLVL\n",
      "XDG_SESSION_CLASS\n",
      "_\n",
      "GPG_AGENT_INFO\n",
      "DESKTOP_SESSION\n",
      "USER\n",
      "XDG_MENU_PREFIX\n",
      "GIO_LAUNCHED_DESKTOP_FILE_PID\n",
      "QT_ACCESSIBILITY\n",
      "WINDOWPATH\n",
      "LC_NUMERIC\n",
      "GJS_DEBUG_OUTPUT\n",
      "SSH_AUTH_SOCK\n",
      "GNOME_SHELL_SESSION_MODE\n",
      "XDG_RUNTIME_DIR\n",
      "HOME\n",
      "JPY_PARENT_PID\n",
      "TERM\n",
      "CLICOLOR\n",
      "PAGER\n",
      "GIT_PAGER\n",
      "MPLBACKEND\n"
     ]
    }
   ],
   "source": [
    "# os.environ是一个字典，其中存放了很多的系统变量，可以通过设置这个东西从而限制系统设备\n",
    "import os\n",
    "for i in os.environ.keys():\n",
    "        print(i)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "outputs": [
    {
     "ename": "Exception",
     "evalue": "process 0 terminated with exit code 1",
     "output_type": "error",
     "traceback": [
      "\u001B[0;31m---------------------------------------------------------------------------\u001B[0m",
      "\u001B[0;31mException\u001B[0m                                 Traceback (most recent call last)",
      "\u001B[0;32m<ipython-input-41-0fda6dbea210>\u001B[0m in \u001B[0;36m<module>\u001B[0;34m\u001B[0m\n\u001B[1;32m      3\u001B[0m     \u001B[0mprint\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0;34m'The {} process{}'\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0mformat\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0mi\u001B[0m\u001B[0;34m,\u001B[0m\u001B[0mc\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[1;32m      4\u001B[0m \u001B[0;34m\u001B[0m\u001B[0m\n\u001B[0;32m----> 5\u001B[0;31m \u001B[0mmp\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0mspawn\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0mfn\u001B[0m\u001B[0;34m=\u001B[0m\u001B[0mtemp\u001B[0m\u001B[0;34m,\u001B[0m\u001B[0mnprocs\u001B[0m\u001B[0;34m=\u001B[0m\u001B[0;36m3\u001B[0m\u001B[0;34m,\u001B[0m\u001B[0margs\u001B[0m\u001B[0;34m=\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0;36m1\u001B[0m\u001B[0;34m,\u001B[0m\u001B[0;36m2\u001B[0m\u001B[0;34m,\u001B[0m\u001B[0;36m3\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[0m\u001B[1;32m      6\u001B[0m \u001B[0;34m\u001B[0m\u001B[0m\n\u001B[1;32m      7\u001B[0m \u001B[0;34m\u001B[0m\u001B[0m\n",
      "\u001B[0;32m~/anaconda3/envs/DL/lib/python3.7/site-packages/torch/multiprocessing/spawn.py\u001B[0m in \u001B[0;36mspawn\u001B[0;34m(fn, args, nprocs, join, daemon, start_method)\u001B[0m\n\u001B[1;32m    197\u001B[0m                ' torch.multiprocessing.start_process(...)' % start_method)\n\u001B[1;32m    198\u001B[0m         \u001B[0mwarnings\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0mwarn\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0mmsg\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[0;32m--> 199\u001B[0;31m     \u001B[0;32mreturn\u001B[0m \u001B[0mstart_processes\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0mfn\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0margs\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0mnprocs\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0mjoin\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0mdaemon\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0mstart_method\u001B[0m\u001B[0;34m=\u001B[0m\u001B[0;34m'spawn'\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[0m",
      "\u001B[0;32m~/anaconda3/envs/DL/lib/python3.7/site-packages/torch/multiprocessing/spawn.py\u001B[0m in \u001B[0;36mstart_processes\u001B[0;34m(fn, args, nprocs, join, daemon, start_method)\u001B[0m\n\u001B[1;32m    155\u001B[0m \u001B[0;34m\u001B[0m\u001B[0m\n\u001B[1;32m    156\u001B[0m     \u001B[0;31m# Loop on join until it returns True or raises an exception.\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[0;32m--> 157\u001B[0;31m     \u001B[0;32mwhile\u001B[0m \u001B[0;32mnot\u001B[0m \u001B[0mcontext\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0mjoin\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m:\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[0m\u001B[1;32m    158\u001B[0m         \u001B[0;32mpass\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[1;32m    159\u001B[0m \u001B[0;34m\u001B[0m\u001B[0m\n",
      "\u001B[0;32m~/anaconda3/envs/DL/lib/python3.7/site-packages/torch/multiprocessing/spawn.py\u001B[0m in \u001B[0;36mjoin\u001B[0;34m(self, timeout)\u001B[0m\n\u001B[1;32m    110\u001B[0m                 raise Exception(\n\u001B[1;32m    111\u001B[0m                     \u001B[0;34m\"process %d terminated with exit code %d\"\u001B[0m \u001B[0;34m%\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[0;32m--> 112\u001B[0;31m                     \u001B[0;34m(\u001B[0m\u001B[0merror_index\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0mexitcode\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[0m\u001B[1;32m    113\u001B[0m                 )\n\u001B[1;32m    114\u001B[0m \u001B[0;34m\u001B[0m\u001B[0m\n",
      "\u001B[0;31mException\u001B[0m: process 0 terminated with exit code 1"
     ]
    }
   ],
   "source": [
    "import torch.multiprocessing as mp\n",
    "def temp(i,a,b,c):\n",
    "    print('The {} process{}'.format(i,c))\n",
    "\n",
    "mp.spawn(fn=temp,nprocs=3,args=(1,2,3))\n"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "outputs": [
    {
     "ename": "Exception",
     "evalue": "process 0 terminated with exit code 1",
     "output_type": "error",
     "traceback": [
      "\u001B[0;31m---------------------------------------------------------------------------\u001B[0m",
      "\u001B[0;31mException\u001B[0m                                 Traceback (most recent call last)",
      "\u001B[0;32m<ipython-input-53-609b0c05ef42>\u001B[0m in \u001B[0;36m<module>\u001B[0;34m\u001B[0m\n\u001B[1;32m     40\u001B[0m             \u001B[0mprint\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0;34m'time:'\u001B[0m\u001B[0;34m,\u001B[0m\u001B[0mtime_use\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[1;32m     41\u001B[0m             \u001B[0mprint\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0;34m'loss:'\u001B[0m\u001B[0;34m,\u001B[0m\u001B[0mloss\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0mitem\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[0;32m---> 42\u001B[0;31m \u001B[0mmp\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0mspawn\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0mfn\u001B[0m\u001B[0;34m=\u001B[0m\u001B[0mmain_worker\u001B[0m\u001B[0;34m,\u001B[0m\u001B[0margs\u001B[0m\u001B[0;34m=\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m,\u001B[0m\u001B[0mnprocs\u001B[0m\u001B[0;34m=\u001B[0m\u001B[0mgpu_nums\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[0m\u001B[1;32m     43\u001B[0m \u001B[0;34m\u001B[0m\u001B[0m\n\u001B[1;32m     44\u001B[0m \u001B[0;34m\u001B[0m\u001B[0m\n",
      "\u001B[0;32m~/anaconda3/envs/DL/lib/python3.7/site-packages/torch/multiprocessing/spawn.py\u001B[0m in \u001B[0;36mspawn\u001B[0;34m(fn, args, nprocs, join, daemon, start_method)\u001B[0m\n\u001B[1;32m    197\u001B[0m                ' torch.multiprocessing.start_process(...)' % start_method)\n\u001B[1;32m    198\u001B[0m         \u001B[0mwarnings\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0mwarn\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0mmsg\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[0;32m--> 199\u001B[0;31m     \u001B[0;32mreturn\u001B[0m \u001B[0mstart_processes\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0mfn\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0margs\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0mnprocs\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0mjoin\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0mdaemon\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0mstart_method\u001B[0m\u001B[0;34m=\u001B[0m\u001B[0;34m'spawn'\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[0m",
      "\u001B[0;32m~/anaconda3/envs/DL/lib/python3.7/site-packages/torch/multiprocessing/spawn.py\u001B[0m in \u001B[0;36mstart_processes\u001B[0;34m(fn, args, nprocs, join, daemon, start_method)\u001B[0m\n\u001B[1;32m    155\u001B[0m \u001B[0;34m\u001B[0m\u001B[0m\n\u001B[1;32m    156\u001B[0m     \u001B[0;31m# Loop on join until it returns True or raises an exception.\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[0;32m--> 157\u001B[0;31m     \u001B[0;32mwhile\u001B[0m \u001B[0;32mnot\u001B[0m \u001B[0mcontext\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0mjoin\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m:\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[0m\u001B[1;32m    158\u001B[0m         \u001B[0;32mpass\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[1;32m    159\u001B[0m \u001B[0;34m\u001B[0m\u001B[0m\n",
      "\u001B[0;32m~/anaconda3/envs/DL/lib/python3.7/site-packages/torch/multiprocessing/spawn.py\u001B[0m in \u001B[0;36mjoin\u001B[0;34m(self, timeout)\u001B[0m\n\u001B[1;32m    110\u001B[0m                 raise Exception(\n\u001B[1;32m    111\u001B[0m                     \u001B[0;34m\"process %d terminated with exit code %d\"\u001B[0m \u001B[0;34m%\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[0;32m--> 112\u001B[0;31m                     \u001B[0;34m(\u001B[0m\u001B[0merror_index\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0mexitcode\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[0m\u001B[1;32m    113\u001B[0m                 )\n\u001B[1;32m    114\u001B[0m \u001B[0;34m\u001B[0m\u001B[0m\n",
      "\u001B[0;31mException\u001B[0m: process 0 terminated with exit code 1"
     ]
    }
   ],
   "source": [
    "import time\n",
    "import torch,torchvision\n",
    "import torch.nn.parallel\n",
    "import torch.distributed as dist\n",
    "import torch.multiprocessing as mp\n",
    "from torch.utils.data.distributed import DistributedSampler\n",
    "from torch.utils.data import DataLoader\n",
    "from torch.nn.parallel import DistributedDataParallel\n",
    "batch = 128\n",
    "gpu_nums = torch.cuda.device_count()\n",
    "def main_worker(local_rank:int):\n",
    "    dist.init_process_group(backend='nccl'\n",
    "                            ,init_method='tcp://127.0.0.1:55555'\n",
    "                            ,world_size=gpu_nums\n",
    "                            ,rank=local_rank)\n",
    "    torch.cuda.set_device(local_rank)\n",
    "    model = torchvision.models.googlenet(pretrained=False)\n",
    "    model.fc = torch.nn.Linear(in_features=1024,out_features=10)\n",
    "    model.cuda(local_rank)\n",
    "\n",
    "    criterion = torch.nn.CrossEntropyLoss().cuda(local_rank)\n",
    "    optimizer = torch.optim.Adam(params=model.parameters()).cuda(local_rank)\n",
    "    #datasets\n",
    "    dataset = torchvision.datasets.MNIST('./MNIST')\n",
    "    sampler = torch.utils.data.distributed.DistributedSampler(dataset=dataset)\n",
    "    data_loader = torch.utils.data.DataLoader(dataset=dataset,batch_size=batch/gpu_nums,sampler=sampler,num_workers=2,pin_memory=True)\n",
    "    for epoch in range(10):\n",
    "        sampler.set_epoch(epoch)\n",
    "        for images,targets in data_loader:\n",
    "            start_time = time.time()\n",
    "            images,targets = images.cuda(local_rank),targets.cuda(local_rank)\n",
    "            out = model(images)\n",
    "            loss = criterion(out,targets)\n",
    "\n",
    "            optimizer.zero_grad()\n",
    "            loss.backward()\n",
    "            optimizer.step()\n",
    "\n",
    "            time_use = time.time()-start_time\n",
    "            print('time:',time_use)\n",
    "            print('loss:',loss.item())\n",
    "mp.spawn(fn=main_worker,args=(),nprocs=gpu_nums)\n"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%% 我自己的distributed分布式训练实验\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Downloading http://yann.lecun.com/exdb/mnist/train-images-idx3-ubyte.gz to ./MNIST/raw/train-images-idx3-ubyte.gz\n"
     ]
    },
    {
     "data": {
      "text/plain": "0it [00:00, ?it/s]",
      "application/vnd.jupyter.widget-view+json": {
       "version_major": 2,
       "version_minor": 0,
       "model_id": "fc4ef30233854aec85517a859375d914"
      }
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "ename": "URLError",
     "evalue": "<urlopen error [Errno -3] Temporary failure in name resolution>",
     "output_type": "error",
     "traceback": [
      "\u001B[0;31m---------------------------------------------------------------------------\u001B[0m",
      "\u001B[0;31mgaierror\u001B[0m                                  Traceback (most recent call last)",
      "\u001B[0;32m~/anaconda3/envs/DL/lib/python3.7/urllib/request.py\u001B[0m in \u001B[0;36mdo_open\u001B[0;34m(self, http_class, req, **http_conn_args)\u001B[0m\n\u001B[1;32m   1349\u001B[0m                 h.request(req.get_method(), req.selector, req.data, headers,\n\u001B[0;32m-> 1350\u001B[0;31m                           encode_chunked=req.has_header('Transfer-encoding'))\n\u001B[0m\u001B[1;32m   1351\u001B[0m             \u001B[0;32mexcept\u001B[0m \u001B[0mOSError\u001B[0m \u001B[0;32mas\u001B[0m \u001B[0merr\u001B[0m\u001B[0;34m:\u001B[0m \u001B[0;31m# timeout error\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n",
      "\u001B[0;32m~/anaconda3/envs/DL/lib/python3.7/http/client.py\u001B[0m in \u001B[0;36mrequest\u001B[0;34m(self, method, url, body, headers, encode_chunked)\u001B[0m\n\u001B[1;32m   1276\u001B[0m         \u001B[0;34m\"\"\"Send a complete request to the server.\"\"\"\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[0;32m-> 1277\u001B[0;31m         \u001B[0mself\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0m_send_request\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0mmethod\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0murl\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0mbody\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0mheaders\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0mencode_chunked\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[0m\u001B[1;32m   1278\u001B[0m \u001B[0;34m\u001B[0m\u001B[0m\n",
      "\u001B[0;32m~/anaconda3/envs/DL/lib/python3.7/http/client.py\u001B[0m in \u001B[0;36m_send_request\u001B[0;34m(self, method, url, body, headers, encode_chunked)\u001B[0m\n\u001B[1;32m   1322\u001B[0m             \u001B[0mbody\u001B[0m \u001B[0;34m=\u001B[0m \u001B[0m_encode\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0mbody\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0;34m'body'\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[0;32m-> 1323\u001B[0;31m         \u001B[0mself\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0mendheaders\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0mbody\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0mencode_chunked\u001B[0m\u001B[0;34m=\u001B[0m\u001B[0mencode_chunked\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[0m\u001B[1;32m   1324\u001B[0m \u001B[0;34m\u001B[0m\u001B[0m\n",
      "\u001B[0;32m~/anaconda3/envs/DL/lib/python3.7/http/client.py\u001B[0m in \u001B[0;36mendheaders\u001B[0;34m(self, message_body, encode_chunked)\u001B[0m\n\u001B[1;32m   1271\u001B[0m             \u001B[0;32mraise\u001B[0m \u001B[0mCannotSendHeader\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[0;32m-> 1272\u001B[0;31m         \u001B[0mself\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0m_send_output\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0mmessage_body\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0mencode_chunked\u001B[0m\u001B[0;34m=\u001B[0m\u001B[0mencode_chunked\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[0m\u001B[1;32m   1273\u001B[0m \u001B[0;34m\u001B[0m\u001B[0m\n",
      "\u001B[0;32m~/anaconda3/envs/DL/lib/python3.7/http/client.py\u001B[0m in \u001B[0;36m_send_output\u001B[0;34m(self, message_body, encode_chunked)\u001B[0m\n\u001B[1;32m   1031\u001B[0m         \u001B[0;32mdel\u001B[0m \u001B[0mself\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0m_buffer\u001B[0m\u001B[0;34m[\u001B[0m\u001B[0;34m:\u001B[0m\u001B[0;34m]\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[0;32m-> 1032\u001B[0;31m         \u001B[0mself\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0msend\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0mmsg\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[0m\u001B[1;32m   1033\u001B[0m \u001B[0;34m\u001B[0m\u001B[0m\n",
      "\u001B[0;32m~/anaconda3/envs/DL/lib/python3.7/http/client.py\u001B[0m in \u001B[0;36msend\u001B[0;34m(self, data)\u001B[0m\n\u001B[1;32m    971\u001B[0m             \u001B[0;32mif\u001B[0m \u001B[0mself\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0mauto_open\u001B[0m\u001B[0;34m:\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[0;32m--> 972\u001B[0;31m                 \u001B[0mself\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0mconnect\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[0m\u001B[1;32m    973\u001B[0m             \u001B[0;32melse\u001B[0m\u001B[0;34m:\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n",
      "\u001B[0;32m~/anaconda3/envs/DL/lib/python3.7/http/client.py\u001B[0m in \u001B[0;36mconnect\u001B[0;34m(self)\u001B[0m\n\u001B[1;32m    943\u001B[0m         self.sock = self._create_connection(\n\u001B[0;32m--> 944\u001B[0;31m             (self.host,self.port), self.timeout, self.source_address)\n\u001B[0m\u001B[1;32m    945\u001B[0m         \u001B[0mself\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0msock\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0msetsockopt\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0msocket\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0mIPPROTO_TCP\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0msocket\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0mTCP_NODELAY\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0;36m1\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n",
      "\u001B[0;32m~/anaconda3/envs/DL/lib/python3.7/socket.py\u001B[0m in \u001B[0;36mcreate_connection\u001B[0;34m(address, timeout, source_address)\u001B[0m\n\u001B[1;32m    706\u001B[0m     \u001B[0merr\u001B[0m \u001B[0;34m=\u001B[0m \u001B[0;32mNone\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[0;32m--> 707\u001B[0;31m     \u001B[0;32mfor\u001B[0m \u001B[0mres\u001B[0m \u001B[0;32min\u001B[0m \u001B[0mgetaddrinfo\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0mhost\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0mport\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0;36m0\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0mSOCK_STREAM\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m:\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[0m\u001B[1;32m    708\u001B[0m         \u001B[0maf\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0msocktype\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0mproto\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0mcanonname\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0msa\u001B[0m \u001B[0;34m=\u001B[0m \u001B[0mres\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n",
      "\u001B[0;32m~/anaconda3/envs/DL/lib/python3.7/socket.py\u001B[0m in \u001B[0;36mgetaddrinfo\u001B[0;34m(host, port, family, type, proto, flags)\u001B[0m\n\u001B[1;32m    751\u001B[0m     \u001B[0maddrlist\u001B[0m \u001B[0;34m=\u001B[0m \u001B[0;34m[\u001B[0m\u001B[0;34m]\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[0;32m--> 752\u001B[0;31m     \u001B[0;32mfor\u001B[0m \u001B[0mres\u001B[0m \u001B[0;32min\u001B[0m \u001B[0m_socket\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0mgetaddrinfo\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0mhost\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0mport\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0mfamily\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0mtype\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0mproto\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0mflags\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m:\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[0m\u001B[1;32m    753\u001B[0m         \u001B[0maf\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0msocktype\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0mproto\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0mcanonname\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0msa\u001B[0m \u001B[0;34m=\u001B[0m \u001B[0mres\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n",
      "\u001B[0;31mgaierror\u001B[0m: [Errno -3] Temporary failure in name resolution",
      "\nDuring handling of the above exception, another exception occurred:\n",
      "\u001B[0;31mURLError\u001B[0m                                  Traceback (most recent call last)",
      "\u001B[0;32m<ipython-input-55-95c0145c4326>\u001B[0m in \u001B[0;36m<module>\u001B[0;34m\u001B[0m\n\u001B[0;32m----> 1\u001B[0;31m \u001B[0mdataset\u001B[0m \u001B[0;34m=\u001B[0m \u001B[0mtorchvision\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0mdatasets\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0mMNIST\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0;34m'./'\u001B[0m\u001B[0;34m,\u001B[0m\u001B[0mdownload\u001B[0m\u001B[0;34m=\u001B[0m\u001B[0;32mTrue\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[0m",
      "\u001B[0;32m~/anaconda3/envs/DL/lib/python3.7/site-packages/torchvision/datasets/mnist.py\u001B[0m in \u001B[0;36m__init__\u001B[0;34m(self, root, train, transform, target_transform, download)\u001B[0m\n\u001B[1;32m     77\u001B[0m             \u001B[0mtarget_transform\u001B[0m\u001B[0;34m:\u001B[0m \u001B[0mOptional\u001B[0m\u001B[0;34m[\u001B[0m\u001B[0mCallable\u001B[0m\u001B[0;34m]\u001B[0m \u001B[0;34m=\u001B[0m \u001B[0;32mNone\u001B[0m\u001B[0;34m,\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[1;32m     78\u001B[0m             \u001B[0mdownload\u001B[0m\u001B[0;34m:\u001B[0m \u001B[0mbool\u001B[0m \u001B[0;34m=\u001B[0m \u001B[0;32mFalse\u001B[0m\u001B[0;34m,\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[0;32m---> 79\u001B[0;31m     ) -> None:\n\u001B[0m\u001B[1;32m     80\u001B[0m         super(MNIST, self).__init__(root, transform=transform,\n\u001B[1;32m     81\u001B[0m                                     target_transform=target_transform)\n",
      "\u001B[0;32m~/anaconda3/envs/DL/lib/python3.7/site-packages/torchvision/datasets/mnist.py\u001B[0m in \u001B[0;36mdownload\u001B[0;34m(self)\u001B[0m\n\u001B[1;32m    144\u001B[0m             \u001B[0;32mreturn\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[1;32m    145\u001B[0m \u001B[0;34m\u001B[0m\u001B[0m\n\u001B[0;32m--> 146\u001B[0;31m         \u001B[0mos\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0mmakedirs\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0mself\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0mraw_folder\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0mexist_ok\u001B[0m\u001B[0;34m=\u001B[0m\u001B[0;32mTrue\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[0m\u001B[1;32m    147\u001B[0m         \u001B[0mos\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0mmakedirs\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0mself\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0mprocessed_folder\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0mexist_ok\u001B[0m\u001B[0;34m=\u001B[0m\u001B[0;32mTrue\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[1;32m    148\u001B[0m \u001B[0;34m\u001B[0m\u001B[0m\n",
      "\u001B[0;32m~/anaconda3/envs/DL/lib/python3.7/site-packages/torchvision/datasets/utils.py\u001B[0m in \u001B[0;36mdownload_and_extract_archive\u001B[0;34m(url, download_root, extract_root, filename, md5, remove_finished)\u001B[0m\n\u001B[1;32m    254\u001B[0m         \u001B[0mfilename\u001B[0m \u001B[0;34m=\u001B[0m \u001B[0mos\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0mpath\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0mbasename\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0murl\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[1;32m    255\u001B[0m \u001B[0;34m\u001B[0m\u001B[0m\n\u001B[0;32m--> 256\u001B[0;31m     \u001B[0mdownload_url\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0murl\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0mdownload_root\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0mfilename\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0mmd5\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[0m\u001B[1;32m    257\u001B[0m \u001B[0;34m\u001B[0m\u001B[0m\n\u001B[1;32m    258\u001B[0m     \u001B[0marchive\u001B[0m \u001B[0;34m=\u001B[0m \u001B[0mos\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0mpath\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0mjoin\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0mdownload_root\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0mfilename\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n",
      "\u001B[0;32m~/anaconda3/envs/DL/lib/python3.7/site-packages/torchvision/datasets/utils.py\u001B[0m in \u001B[0;36mdownload_url\u001B[0;34m(url, root, filename, md5)\u001B[0m\n\u001B[1;32m     82\u001B[0m                 )\n\u001B[1;32m     83\u001B[0m             \u001B[0;32melse\u001B[0m\u001B[0;34m:\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[0;32m---> 84\u001B[0;31m                 \u001B[0;32mraise\u001B[0m \u001B[0me\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[0m\u001B[1;32m     85\u001B[0m         \u001B[0;31m# check integrity of downloaded file\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[1;32m     86\u001B[0m         \u001B[0;32mif\u001B[0m \u001B[0;32mnot\u001B[0m \u001B[0mcheck_integrity\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0mfpath\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0mmd5\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m:\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n",
      "\u001B[0;32m~/anaconda3/envs/DL/lib/python3.7/site-packages/torchvision/datasets/utils.py\u001B[0m in \u001B[0;36mdownload_url\u001B[0;34m(url, root, filename, md5)\u001B[0m\n\u001B[1;32m     70\u001B[0m             urllib.request.urlretrieve(\n\u001B[1;32m     71\u001B[0m                 \u001B[0murl\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0mfpath\u001B[0m\u001B[0;34m,\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[0;32m---> 72\u001B[0;31m                 \u001B[0mreporthook\u001B[0m\u001B[0;34m=\u001B[0m\u001B[0mgen_bar_updater\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[0m\u001B[1;32m     73\u001B[0m             )\n\u001B[1;32m     74\u001B[0m         \u001B[0;32mexcept\u001B[0m \u001B[0;34m(\u001B[0m\u001B[0murllib\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0merror\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0mURLError\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0mIOError\u001B[0m\u001B[0;34m)\u001B[0m \u001B[0;32mas\u001B[0m \u001B[0me\u001B[0m\u001B[0;34m:\u001B[0m  \u001B[0;31m# type: ignore[attr-defined]\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n",
      "\u001B[0;32m~/anaconda3/envs/DL/lib/python3.7/urllib/request.py\u001B[0m in \u001B[0;36murlretrieve\u001B[0;34m(url, filename, reporthook, data)\u001B[0m\n\u001B[1;32m    245\u001B[0m     \u001B[0murl_type\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0mpath\u001B[0m \u001B[0;34m=\u001B[0m \u001B[0msplittype\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0murl\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[1;32m    246\u001B[0m \u001B[0;34m\u001B[0m\u001B[0m\n\u001B[0;32m--> 247\u001B[0;31m     \u001B[0;32mwith\u001B[0m \u001B[0mcontextlib\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0mclosing\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0murlopen\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0murl\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0mdata\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m)\u001B[0m \u001B[0;32mas\u001B[0m \u001B[0mfp\u001B[0m\u001B[0;34m:\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[0m\u001B[1;32m    248\u001B[0m         \u001B[0mheaders\u001B[0m \u001B[0;34m=\u001B[0m \u001B[0mfp\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0minfo\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[1;32m    249\u001B[0m \u001B[0;34m\u001B[0m\u001B[0m\n",
      "\u001B[0;32m~/anaconda3/envs/DL/lib/python3.7/urllib/request.py\u001B[0m in \u001B[0;36murlopen\u001B[0;34m(url, data, timeout, cafile, capath, cadefault, context)\u001B[0m\n\u001B[1;32m    220\u001B[0m     \u001B[0;32melse\u001B[0m\u001B[0;34m:\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[1;32m    221\u001B[0m         \u001B[0mopener\u001B[0m \u001B[0;34m=\u001B[0m \u001B[0m_opener\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[0;32m--> 222\u001B[0;31m     \u001B[0;32mreturn\u001B[0m \u001B[0mopener\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0mopen\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0murl\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0mdata\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0mtimeout\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[0m\u001B[1;32m    223\u001B[0m \u001B[0;34m\u001B[0m\u001B[0m\n\u001B[1;32m    224\u001B[0m \u001B[0;32mdef\u001B[0m \u001B[0minstall_opener\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0mopener\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m:\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n",
      "\u001B[0;32m~/anaconda3/envs/DL/lib/python3.7/urllib/request.py\u001B[0m in \u001B[0;36mopen\u001B[0;34m(self, fullurl, data, timeout)\u001B[0m\n\u001B[1;32m    523\u001B[0m             \u001B[0mreq\u001B[0m \u001B[0;34m=\u001B[0m \u001B[0mmeth\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0mreq\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[1;32m    524\u001B[0m \u001B[0;34m\u001B[0m\u001B[0m\n\u001B[0;32m--> 525\u001B[0;31m         \u001B[0mresponse\u001B[0m \u001B[0;34m=\u001B[0m \u001B[0mself\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0m_open\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0mreq\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0mdata\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[0m\u001B[1;32m    526\u001B[0m \u001B[0;34m\u001B[0m\u001B[0m\n\u001B[1;32m    527\u001B[0m         \u001B[0;31m# post-process response\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n",
      "\u001B[0;32m~/anaconda3/envs/DL/lib/python3.7/urllib/request.py\u001B[0m in \u001B[0;36m_open\u001B[0;34m(self, req, data)\u001B[0m\n\u001B[1;32m    541\u001B[0m         \u001B[0mprotocol\u001B[0m \u001B[0;34m=\u001B[0m \u001B[0mreq\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0mtype\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[1;32m    542\u001B[0m         result = self._call_chain(self.handle_open, protocol, protocol +\n\u001B[0;32m--> 543\u001B[0;31m                                   '_open', req)\n\u001B[0m\u001B[1;32m    544\u001B[0m         \u001B[0;32mif\u001B[0m \u001B[0mresult\u001B[0m\u001B[0;34m:\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[1;32m    545\u001B[0m             \u001B[0;32mreturn\u001B[0m \u001B[0mresult\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n",
      "\u001B[0;32m~/anaconda3/envs/DL/lib/python3.7/urllib/request.py\u001B[0m in \u001B[0;36m_call_chain\u001B[0;34m(self, chain, kind, meth_name, *args)\u001B[0m\n\u001B[1;32m    501\u001B[0m         \u001B[0;32mfor\u001B[0m \u001B[0mhandler\u001B[0m \u001B[0;32min\u001B[0m \u001B[0mhandlers\u001B[0m\u001B[0;34m:\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[1;32m    502\u001B[0m             \u001B[0mfunc\u001B[0m \u001B[0;34m=\u001B[0m \u001B[0mgetattr\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0mhandler\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0mmeth_name\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[0;32m--> 503\u001B[0;31m             \u001B[0mresult\u001B[0m \u001B[0;34m=\u001B[0m \u001B[0mfunc\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0;34m*\u001B[0m\u001B[0margs\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[0m\u001B[1;32m    504\u001B[0m             \u001B[0;32mif\u001B[0m \u001B[0mresult\u001B[0m \u001B[0;32mis\u001B[0m \u001B[0;32mnot\u001B[0m \u001B[0;32mNone\u001B[0m\u001B[0;34m:\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[1;32m    505\u001B[0m                 \u001B[0;32mreturn\u001B[0m \u001B[0mresult\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n",
      "\u001B[0;32m~/anaconda3/envs/DL/lib/python3.7/urllib/request.py\u001B[0m in \u001B[0;36mhttp_open\u001B[0;34m(self, req)\u001B[0m\n\u001B[1;32m   1376\u001B[0m \u001B[0;34m\u001B[0m\u001B[0m\n\u001B[1;32m   1377\u001B[0m     \u001B[0;32mdef\u001B[0m \u001B[0mhttp_open\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0mself\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0mreq\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m:\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[0;32m-> 1378\u001B[0;31m         \u001B[0;32mreturn\u001B[0m \u001B[0mself\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0mdo_open\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0mhttp\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0mclient\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0mHTTPConnection\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0mreq\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[0m\u001B[1;32m   1379\u001B[0m \u001B[0;34m\u001B[0m\u001B[0m\n\u001B[1;32m   1380\u001B[0m     \u001B[0mhttp_request\u001B[0m \u001B[0;34m=\u001B[0m \u001B[0mAbstractHTTPHandler\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0mdo_request_\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n",
      "\u001B[0;32m~/anaconda3/envs/DL/lib/python3.7/urllib/request.py\u001B[0m in \u001B[0;36mdo_open\u001B[0;34m(self, http_class, req, **http_conn_args)\u001B[0m\n\u001B[1;32m   1350\u001B[0m                           encode_chunked=req.has_header('Transfer-encoding'))\n\u001B[1;32m   1351\u001B[0m             \u001B[0;32mexcept\u001B[0m \u001B[0mOSError\u001B[0m \u001B[0;32mas\u001B[0m \u001B[0merr\u001B[0m\u001B[0;34m:\u001B[0m \u001B[0;31m# timeout error\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[0;32m-> 1352\u001B[0;31m                 \u001B[0;32mraise\u001B[0m \u001B[0mURLError\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0merr\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[0m\u001B[1;32m   1353\u001B[0m             \u001B[0mr\u001B[0m \u001B[0;34m=\u001B[0m \u001B[0mh\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0mgetresponse\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[1;32m   1354\u001B[0m         \u001B[0;32mexcept\u001B[0m\u001B[0;34m:\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n",
      "\u001B[0;31mURLError\u001B[0m: <urlopen error [Errno -3] Temporary failure in name resolution>"
     ]
    }
   ],
   "source": [],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}